package com.young.springdemo.service.policy;

import com.young.springdemo.service.BuildModelTest.Model;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author Young
 * @description 该策略类实现的方式还是比较简单的,包括手工去配置具体实现类时,都是比较不方便,新实现了
 * 一个集成所有项目中的策略,然后根据具体执行的策略来使用的..具体的实现代码在同级strategy包下...
 * @date 9:23 2020/5/18
 * @return
 **/
//@Component
public class TestPolicy {

//    @PostConstruct
    public void test() throws  Exception {
        MoviTicker moviTicker = new MoviTicker();
        moviTicker.setPrice(100);
        System.out.println("电影票原价:"+moviTicker.getPrice());

        //构造策略类
        Class<?> forName = Class.forName("com.young.springdemo.service.policy.ChildrenDiscount");
        Discount discount = (Discount) forName.newInstance();

        moviTicker.setDiscount(discount);
        System.out.println("电影票打完折,价格为:"+moviTicker.getPrice());

    }
}
